<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <th:block th:include="include :: header('添加部门')"/>
    <th:block th:include="include :: dtree_css"/>
</head>
<body class="x-admin-sm">
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">

            <div class="layui-form-item">
                <label for="postName" class="layui-form-label">
                    <span class="x-red">*</span>岗位名称
                </label>
                <div class="layui-input-block">
                    <input type="text" id="postName" name="postName" th:value="${sysPost.postName}" required="" lay-verify="required|postName"
                           autocomplete="off" class="layui-input">
                    <input type="hidden" name="postId" th:value="${sysPost.postId}">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="postCode" class="layui-form-label">
                    <span class="x-red">*</span>岗位编码
                </label>
                <div class="layui-input-block">
                    <input type="text" id="postCode" name="postCode" th:value="${sysPost.postCode}" required="" lay-verify="required|postCode"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>英文字符串 "ceo"、"boos" 。。。。
                </div>
            </div>

            <div class="layui-form-item">
                <label for="postSort" class="layui-form-label">
                    <span class="x-red">*</span>显示顺序
                </label>
                <div class="layui-input-block">
                    <input type="text" id="postSort" name="postSort" th:value="${sysPost.postSort}" required="" lay-verify="required|num"
                           autocomplete="off" class="layui-input">
                </div>
            </div>


            <div class="layui-form-item">
                <label for="remark" class="layui-form-label">
                    <span class="x-red">*</span>备注
                </label>
                <div class="layui-input-block">
                    <textarea id="remark" name="remark" required="" th:text="${sysPost.remark}" lay-verify="required"
                              autocomplete="off" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="status" class="layui-form-label">
                    <span class="x-red">*</span>菜单状态
                </label>
                <div class="layui-input-block" id="status" >
                    <input type="radio" name="status" value="0" title="显示" th:checked="${sysPost.status=='0'? true: false}">
                    <input type="radio" name="status" value="1" title="隐藏" th:checked="${sysPost.status=='1'? true: false}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                </label>
                <button class="layui-btn" lay-filter="edit" lay-submit="">
                    修改
                </button>
            </div>
        </form>
    </div>
</div>
<script th:inline="javascript"> var ctx = [[@{/}]] </script>
<script>

    layui.use(['form', 'layer', 'dtree'],function () {
        $ = layui.jquery;
        var form = layui.form;
        var layer = layui.layer;

        //表单数据校验
        form.verify({
            postName:function (value) {

            },
            postCode:function (value) {

            }
        });



        //监听表单提交事件
        form.on('submit(edit)',function (obj) {
            // layer.msg(JSON.stringify(obj.field));
            $.ajax({
                url:ctx+'system/post/update',
                type:'POST',
                data:obj.field,
                success:function (res) {
                    layer.msg(res.msg);
                    if(res.code===0){
                        //表格刷新
                        parent.layui.table.reload("postTable");
                        xadmin.close();
                        // 可以对父窗口进行刷新
                        xadmin.father_reload();
                    }

                }

            });
            return false;
        });


    });
</script>
</body>
</html>